# frozen_string_literal: true

# == Schema Information
#
# Table name: coupons
#
#  id          :integer          not null, primary key
#  user_id     :integer
#  name        :string
#  code        :string
#  purpose     :string
#  begin_date  :string
#  end_date    :string
#  receive     :boolean          default(FALSE)
#  region      :string
#  state       :boolean          default(FALSE)
#  kind        :string
#  created_at  :datetime         not null
#  updated_at  :datetime         not null
#  price       :decimal(, )
#  limit_state :boolean          default(FALSE)
#  url         :string
#  show_index  :string
#

class Coupon < ApplicationRecord
  belongs_to :user, optional: true
  attr_accessor :receive_count

  def self.generate_code
    code = [*('a'..'z'), *(0..9)].sample(10).join
   end
end
